package com.exchange.used.web.api;

import com.exchange.used.config.converters.LayuiResult;
import com.exchange.used.config.query.Condition;
import com.exchange.used.service.OrderServiceI;
import com.exchange.used.service.UserServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    UserServiceI userServiceI;
    @Autowired
    OrderServiceI orderServiceI;

    @RequestMapping(value = "/add/{goodsid}/{goodsnum}/{fkaddressid}", method = RequestMethod.GET)
    public LayuiResult add(@PathVariable String goodsid,
                           @PathVariable Integer goodsnum,
                           @PathVariable String fkaddressid){
        return orderServiceI.addOrder(goodsid, goodsnum, fkaddressid);
    }

    @RequestMapping(value = "/batchAdd", method = RequestMethod.POST)
    public LayuiResult batchAdd(@RequestBody Map<String, Object> order){
        return orderServiceI.batchAddOrder(order);
    }

    @RequestMapping(value = "/find", method = RequestMethod.POST)
    public LayuiResult find(@RequestBody Condition condition){
        return orderServiceI.findUserOrder(condition);
    }

    @RequestMapping(value = "/stateFinish/{orderid}", method = RequestMethod.GET)
    public LayuiResult stateFinish(@PathVariable String orderid){
        return orderServiceI.stateFinish(orderid);
    }

    @RequestMapping(value = "/stateCancel/{orderid}", method = RequestMethod.GET)
    public LayuiResult stateCancel(@PathVariable String orderid){
        return orderServiceI.stateCancel(orderid);
    }

    @RequestMapping(value = "/remark", method = RequestMethod.POST)
    public LayuiResult remark(@RequestBody Map<String, Object> record){
        return orderServiceI.remark(record);
    }


}
